/*
 * Copyright (c) 2011, Michael van der Westhuizen
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *    - Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *    - Redistributions in binary form must reproduce the above
 *      copyright notice, this list of conditions and the following
 *      disclaimer in the documentation and/or other materials provided
 *      with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
#ifndef PYXMLSEC1_APP_C_MCVDW_20110216
#define PYXMLSEC1_APP_C_MCVDW_20110216

#include "pyxmlsec.h"

#include <xmlsec/app.h>



static PyObject * xmlsec1_xmlSecCryptoInit(PyObject * self, PyObject * arg)
{
    if (0 != xmlSecCryptoInit())
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoInit);
        return NULL;
    }

    Py_RETURN_NONE;
}



static PyObject * xmlsec1_xmlSecCryptoShutdown(PyObject * self, PyObject * arg)
{
    if (0 != xmlSecCryptoShutdown())
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoShutdown);
        return NULL;
    }

    Py_RETURN_NONE;
}



static PyObject * xmlsec1_xmlSecCryptoKeysMngrInit(PyObject * self, PyObject * arg)
{
    xmlSecKeysMngrPtr mngr;

    if (NULL == (mngr = xmlsec1mod_unwrap_xmlSecKeysMngrPtr(arg)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_unwrap_xmlSecKeysMngrPtr);
        return NULL;
    }

    if (0 != xmlSecCryptoKeysMngrInit(mngr))
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoKeysMngrInit);
        return NULL;
    }

    Py_RETURN_NONE;
}



static PyObject * xmlsec1_xmlSecKeyDataAesGetKlass(PyObject * self, PyObject * arg)
{
    xmlSecKeyDataId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecKeyDataAesGetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecKeyDataAesGetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecKeyDataId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecKeyDataId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecKeyDataDesGetKlass(PyObject * self, PyObject * arg)
{
    xmlSecKeyDataId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecKeyDataDesGetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecKeyDataDesGetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecKeyDataId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecKeyDataId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecKeyDataDsaGetKlass(PyObject * self, PyObject * arg)
{
    xmlSecKeyDataId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecKeyDataDsaGetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecKeyDataDsaGetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecKeyDataId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecKeyDataId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecKeyDataGost2001GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecKeyDataId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecKeyDataGost2001GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecKeyDataGost2001GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecKeyDataId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecKeyDataId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecKeyDataHmacGetKlass(PyObject * self, PyObject * arg)
{
    xmlSecKeyDataId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecKeyDataHmacGetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecKeyDataHmacGetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecKeyDataId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecKeyDataId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecKeyDataRsaGetKlass(PyObject * self, PyObject * arg)
{
    xmlSecKeyDataId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecKeyDataRsaGetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecKeyDataRsaGetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecKeyDataId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecKeyDataId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecKeyDataX509GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecKeyDataId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecKeyDataX509GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecKeyDataX509GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecKeyDataId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecKeyDataId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecKeyDataRawX509CertGetKlass(PyObject * self, PyObject * arg)
{
    xmlSecKeyDataId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecKeyDataRawX509CertGetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecKeyDataRawX509CertGetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecKeyDataId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecKeyDataId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecX509StoreGetKlass(PyObject * self, PyObject * arg)
{
    xmlSecKeyDataStoreId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecX509StoreGetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecX509StoreGetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecKeyDataStoreId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecKeyDataStoreId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformAes128CbcGetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformAes128CbcGetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformAes128CbcGetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformAes192CbcGetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformAes192CbcGetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformAes192CbcGetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformAes256CbcGetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformAes256CbcGetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformAes256CbcGetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformKWAes128GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformKWAes128GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformKWAes128GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformKWAes192GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformKWAes192GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformKWAes192GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformKWAes256GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformKWAes256GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformKWAes256GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformDes3CbcGetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformDes3CbcGetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformDes3CbcGetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformKWDes3GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformKWDes3GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformKWDes3GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformDsaSha1GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformDsaSha1GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformDsaSha1GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformGost2001GostR3411_94GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformGost2001GostR3411_94GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformGost2001GostR3411_94GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformHmacMd5GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformHmacMd5GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformHmacMd5GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformHmacRipemd160GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformHmacRipemd160GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformHmacRipemd160GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformHmacSha1GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformHmacSha1GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformHmacSha1GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformHmacSha224GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformHmacSha224GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformHmacSha224GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformHmacSha256GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformHmacSha256GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformHmacSha256GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformHmacSha384GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformHmacSha384GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformHmacSha384GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformHmacSha512GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformHmacSha512GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformHmacSha512GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformMd5GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformMd5GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformMd5GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformRipemd160GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformRipemd160GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformRipemd160GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformRsaMd5GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformRsaMd5GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformRsaMd5GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformRsaRipemd160GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformRsaRipemd160GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformRsaRipemd160GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformRsaSha1GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformRsaSha1GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformRsaSha1GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformRsaSha224GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformRsaSha224GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformRsaSha224GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformRsaSha256GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformRsaSha256GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformRsaSha256GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformRsaSha384GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformRsaSha384GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformRsaSha384GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformRsaSha512GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformRsaSha512GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformRsaSha512GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformRsaPkcs1GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformRsaPkcs1GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformRsaPkcs1GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformRsaOaepGetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformRsaOaepGetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformRsaOaepGetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformGostR3411_94GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformGostR3411_94GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformGostR3411_94GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformSha1GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformSha1GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformSha1GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformSha224GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformSha224GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformSha224GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformSha256GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformSha256GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformSha256GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformSha384GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformSha384GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformSha384GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecTransformSha512GetKlass(PyObject * self, PyObject * arg)
{
    xmlSecTransformId ptr;
    PyObject * ret;

    if (NULL == (ptr = xmlSecTransformSha512GetKlass()))
    {
        ENSURE_EXCEPTION_SET(xmlSecTransformSha512GetKlass);
        return NULL;
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecTransformId(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecTransformId);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecCryptoAppInit(PyObject * self, PyObject * arg)
{
    int ret;

    if (Py_None == arg)
    {
        ret = xmlSecCryptoAppInit(NULL);
    }
    else if (PyUnicode_Check(arg))
    {
        PyObject * tmp;

        if (NULL == (tmp = PyUnicode_AsUTF8String(arg)))
        {
            ENSURE_EXCEPTION_SET(PyUnicode_AsUTF8String);
            return NULL;
        }

        ret = xmlSecCryptoAppInit(PyBytes_AsString(arg));
        Py_DECREF(tmp);
    }
    else if (PyBytes_Check(arg))
    {
        ret = xmlSecCryptoAppInit(PyBytes_AsString(arg));
    }
    else
    {
        PyErr_SetString(PyExc_TypeError, "input must be of type bytes (string), unicode or None");
        return NULL;
    }

    if (0 != ret)
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppInit);
        return NULL;
    }

    Py_RETURN_NONE;
}



static PyObject * xmlsec1_xmlSecCryptoAppShutdown(PyObject * self, PyObject * arg)
{
    if (0 != xmlSecCryptoAppShutdown())
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppShutdown);
        return NULL;
    }

    Py_RETURN_NONE;
}



static PyObject * xmlsec1_xmlSecCryptoAppDefaultKeysMngrInit(PyObject * self, PyObject * arg)
{
    xmlSecKeysMngrPtr mngr;

    if (NULL == (mngr = xmlsec1mod_unwrap_xmlSecKeysMngrPtr(arg)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_unwrap_xmlSecKeysMngrPtr);
        return NULL;
    }

    if (0 != xmlSecCryptoAppDefaultKeysMngrInit(mngr))
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppDefaultKeysMngrInit);
        return NULL;
    }

    Py_RETURN_NONE;
}



static PyObject * xmlsec1_xmlSecCryptoAppDefaultKeysMngrAdoptKey(PyObject * self, PyObject * args, PyObject * kwds)
{
    PyObject * arg1;
    PyObject * arg2;
    xmlSecKeysMngrPtr mngr;
    xmlSecKeyPtr key;

    static char * kwlist[] = {"mngr", "key", NULL};

    arg1 = arg2 = NULL;
    mngr = NULL;
    key = NULL;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &arg1, &arg2))
    {
        return NULL;
    }

    if (NULL == (mngr = xmlsec1mod_unwrap_xmlSecKeysMngrPtr(arg1)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_unwrap_xmlSecKeysMngrPtr);
        return NULL;
    }

    if (NULL == (key = xmlsec1mod_unwrap_xmlSecKeyPtr(arg2)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_unwrap_xmlSecKeyPtr);
        return NULL;
    }

    if (0 != xmlSecCryptoAppDefaultKeysMngrAdoptKey(mngr, key))
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppDefaultKeysMngrAdoptKey);
        return NULL;
    }

    Py_RETURN_NONE;
}



static PyObject * xmlsec1_xmlSecCryptoAppDefaultKeysMngrLoad(PyObject * self, PyObject * args, PyObject * kwds)
{
    PyObject * arg1;
    xmlSecKeysMngrPtr mngr;
    char * uri;

    static char * kwlist[] = {"mngr", "uri", NULL};

    arg1 = NULL;
    mngr = NULL;
    uri = NULL;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "Os", kwlist, &arg1, &uri))
    {
        return NULL;
    }

    if (NULL == (mngr = xmlsec1mod_unwrap_xmlSecKeysMngrPtr(arg1)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_unwrap_xmlSecKeysMngrPtr);
        return NULL;
    }

    if (0 != xmlSecCryptoAppDefaultKeysMngrLoad(mngr, uri))
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppDefaultKeysMngrLoad);
        return NULL;
    }

    Py_RETURN_NONE;
}



static PyObject * xmlsec1_xmlSecCryptoAppDefaultKeysMngrSave(PyObject * self, PyObject * args, PyObject * kwds)
{
    PyObject * arg1;
    xmlSecKeysMngrPtr mngr;
    char * filename;
    unsigned int dtype_;
    xmlSecKeyDataType dtype;

    static char * kwlist[] = {"mngr", "filename", "dtype", NULL};

    arg1 = NULL;
    mngr = NULL;
    filename = NULL;
    dtype_ = 0;
    dtype = xmlSecKeyDataTypeUnknown;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "OsI", kwlist, &arg1, &filename, &dtype_))
    {
        return NULL;
    }

    if (NULL == (mngr = xmlsec1mod_unwrap_xmlSecKeysMngrPtr(arg1)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_unwrap_xmlSecKeysMngrPtr);
        return NULL;
    }

    dtype = (xmlSecKeyDataType)dtype_;

    if (0 != xmlSecCryptoAppDefaultKeysMngrSave(mngr, filename, dtype))
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppDefaultKeysMngrSave);
        return NULL;
    }

    Py_RETURN_NONE;
}



static PyObject * xmlsec1_xmlSecCryptoAppKeysMngrCertLoad(PyObject * self, PyObject * args, PyObject * kwds)
{
    PyObject * arg1;
    char * filename;
    int arg3;
    unsigned int arg4;
    xmlSecKeysMngrPtr mngr;
    xmlSecKeyDataFormat format;
    xmlSecKeyDataType ktype;

    static char * kwlist[] = {"mngr", "filename", "format", "ktype", NULL};

    arg1 = NULL;
    filename = NULL;
    arg3 = 0;
    arg4 = 0;
    mngr = NULL;
    format = xmlSecKeyDataFormatUnknown;
    ktype = xmlSecKeyDataTypeUnknown;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "OsiI", kwlist, &arg1, &filename, &arg3, &arg4))
    {
        return NULL;
    }

    if (NULL == (mngr = xmlsec1mod_unwrap_xmlSecKeysMngrPtr(arg1)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_unwrap_xmlSecKeysMngrPtr);
        return NULL;
    }

    format = (xmlSecKeyDataFormat)arg3;
    ktype = (xmlSecKeyDataType)arg4;

    if (0 != xmlSecCryptoAppKeysMngrCertLoad(mngr, filename, format, ktype))
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppKeysMngrCertLoad);
        return NULL;
    }

    Py_RETURN_NONE;
}



static PyObject * xmlsec1_xmlSecCryptoAppKeysMngrCertLoadMemory(PyObject * self, PyObject * args, PyObject * kwds)
{
    PyObject * arg1;
    PyObject * arg2;
    int arg3;
    unsigned int arg4;
    xmlSecKeysMngrPtr mngr;
    xmlSecByte * data;
    xmlSecSize dataSize;
    xmlSecKeyDataFormat format;
    xmlSecKeyDataType ktype;

    static char * kwlist[] = {"mngr", "buffer", "format", "ktype", NULL};

    arg1 = arg2 =  NULL;
    arg3 = 0;
    arg4 = 0;
    mngr = NULL;
    format = xmlSecKeyDataFormatUnknown;
    ktype = xmlSecKeyDataTypeUnknown;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOiI", kwlist, &arg1, &arg2, &arg3, &arg4))
    {
        return NULL;
    }

    if (NULL == (mngr = xmlsec1mod_unwrap_xmlSecKeysMngrPtr(arg1)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_unwrap_xmlSecKeysMngrPtr);
        return NULL;
    }

    if (0 != xmlsec1_ByteArrayOrBytesToXmlSecBytes(arg2, &data, &dataSize))
    {
        ENSURE_EXCEPTION_SET(xmlsec1_ByteArrayOrBytesToXmlSecBytes);
        return NULL;
    }

    format = (xmlSecKeyDataFormat)arg3;
    ktype = (xmlSecKeyDataType)arg4;

    if (0 != xmlSecCryptoAppKeysMngrCertLoadMemory(mngr, data, dataSize, format, ktype))
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppKeysMngrCertLoad);
        PyMem_Del(data);
        return NULL;
    }

    PyMem_Del(data);
    Py_RETURN_NONE;
}



typedef struct
{
    PyObject * callable;
    PyObject * userdata;
} PasswordCallbackUserDataType;



static int xmlsec1_xmlSecPasswordCallbackWrapper(char * buf, int bufsize, int verify, void * userdata)
{
    PyGILState_STATE gstate;
    PyObject * filename;
    PyObject * verify_;
    PyObject * userdata_;
    PyObject * dict;
    PyObject * res;
    PasswordCallbackUserDataType * ud;
    char * rstr;
    Py_ssize_t length;

    ud = (PasswordCallbackUserDataType *)userdata;

    gstate = PyGILState_Ensure();

    if (!PyCallable_Check(ud->callable))
    {
        PyGILState_Release(gstate);
        return -1;
    }

    if (buf && *buf)
    {
        if (NULL == (filename = Py_BuildValue("s", buf)))
        {
            PyGILState_Release(gstate);
            return -1;
        }
    }
    else
    {
        Py_INCREF(Py_None);
        filename = Py_None;
    }

    verify_ = PyBool_FromLong((long)verify);

    if (NULL != ud && NULL != ud->userdata)
    {
        Py_INCREF(ud->userdata);
        userdata_ = ud->userdata;
    }
    else
    {
        Py_INCREF(Py_None);
        userdata_ = Py_None;
    }

    if (NULL == (dict = Py_BuildValue("{s:O, s:O, s:O}", "filename", filename, "verify", verify_, "userdata", userdata_)))
    {
        Py_DECREF(filename);
        Py_DECREF(verify_);
        Py_DECREF(userdata_);
        PyGILState_Release(gstate);
        return -1;
    }

    Py_CLEAR(filename);
    Py_CLEAR(verify_);
    Py_CLEAR(userdata_);

    Py_INCREF(ud->callable);

    if (NULL == (res = PyObject_Call(ud->callable, NULL, dict)))
    {
        Py_CLEAR(dict);
        Py_DECREF(ud->callable);
        PyGILState_Release(gstate);
        return -1;
    }

    Py_CLEAR(dict);
    Py_DECREF(ud->callable);

    memset(buf, '\0', bufsize);

    if (Py_None == res)
    {
        length = 0;
    }
    else
    {
        if (0 != PyString_AsStringAndSize(res, &rstr, &length))
        {
            Py_DECREF(res);
            PyGILState_Release(gstate);
            return -1;
        }

        if (bufsize > (length + 1))
        {
            Py_DECREF(res);
            PyGILState_Release(gstate);
            return -1;
        }

        memcpy(buf, rstr, (size_t)length);
    }

    Py_DECREF(res);
    PyGILState_Release(gstate);

    return (int)length;
}



static PyObject * xmlsec1_xmlSecCryptoAppKeyLoad(PyObject * self, PyObject * args, PyObject * kwds)
{
    char * filename;
    int arg2;
    char * password;
    xmlSecKeyDataFormat format;
    PyObject * callback;
    PyObject * userdata;
    xmlSecKeyPtr ptr;
    PyObject * ret;
    void * cb;
    PasswordCallbackUserDataType cbdata_;
    PasswordCallbackUserDataType * cbdata;

    static char * kwlist[] = {"filename", "format", "pwd", "pwdCallback", "pwdCallbackCtx", NULL};

    filename = password = NULL;
    arg2 = 0;
    format = xmlSecKeyDataFormatUnknown;
    callback = userdata = NULL;
    ptr = NULL;
    ret = NULL;
    cb = NULL;
    cbdata = NULL;

    memset(&cbdata_, '\0', sizeof(cbdata_));

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "si|sOO", kwlist, &filename, &arg2, &password, &callback, &userdata))
    {
        return NULL;
    }

    format = (xmlSecKeyDataFormat)arg2;

    if (NULL != callback)
    {
        Py_INCREF(callback);
        cbdata_.callable = callback;

        if (NULL != userdata)
        {
            Py_INCREF(userdata);
            cbdata_.userdata = userdata;
        }

        cbdata = &cbdata_;
        cb = (void *)&xmlsec1_xmlSecPasswordCallbackWrapper;
    }

    if (NULL == (ptr = xmlSecCryptoAppKeyLoad(filename, format, password, cb, cbdata)))
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppKeyLoad);

        if (NULL != cbdata)
        {
            Py_XDECREF(cbdata->callable);
            Py_XDECREF(cbdata->userdata);
        }

        return NULL;
    }

    if (NULL != cbdata)
    {
        Py_XDECREF(cbdata->callable);
        Py_XDECREF(cbdata->userdata);
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecKeyPtr(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecKeyPtr);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecCryptoAppKeyLoadMemory(PyObject * self, PyObject * args, PyObject * kwds)
{
    PyObject * arg1;
    int arg2;
    char * password;
    xmlSecKeyDataFormat format;
    PyObject * callback;
    PyObject * userdata;
    xmlSecKeyPtr ptr;
    PyObject * ret;
    void * cb;
    xmlSecByte * data;
    xmlSecSize dataSize;
    PasswordCallbackUserDataType cbdata_;
    PasswordCallbackUserDataType * cbdata;

    static char * kwlist[] = {"data", "format", "pwd", "pwdCallback", "pwdCallbackCtx", NULL};

    password = NULL;
    arg1 = NULL;
    arg2 = 0;
    format = xmlSecKeyDataFormatUnknown;
    callback = userdata = NULL;
    ptr = NULL;
    ret = NULL;
    cb = NULL;
    cbdata = NULL;

    memset(&cbdata_, '\0', sizeof(cbdata_));

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "Oi|sOO", kwlist, &arg1, &arg2, &password, &callback, &userdata))
    {
        return NULL;
    }

    format = (xmlSecKeyDataFormat)arg2;

    if (0 != xmlsec1_ByteArrayOrBytesToXmlSecBytes(arg1, &data, &dataSize))
    {
        ENSURE_EXCEPTION_SET(xmlsec1_ByteArrayOrBytesToXmlSecBytes);
        return NULL;
    }

    if (NULL != callback)
    {
        Py_INCREF(callback);
        cbdata_.callable = callback;

        if (NULL != userdata)
        {
            Py_INCREF(userdata);
            cbdata_.userdata = userdata;
        }

        cbdata = &cbdata_;
        cb = (void *)&xmlsec1_xmlSecPasswordCallbackWrapper;
    }

    if (NULL == (ptr = xmlSecCryptoAppKeyLoadMemory(data, dataSize, format, password, cb, cbdata)))
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppKeyLoad);

        if (NULL != cbdata)
        {
            Py_XDECREF(cbdata->callable);
            Py_XDECREF(cbdata->userdata);
        }

        PyMem_Del(data);
        return NULL;
    }

    PyMem_Del(data);
    if (NULL != cbdata)
    {
        Py_XDECREF(cbdata->callable);
        Py_XDECREF(cbdata->userdata);
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecKeyPtr(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecKeyPtr);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecCryptoAppPkcs12Load(PyObject * self, PyObject * args, PyObject * kwds)
{
    char * filename;
    char * password;
    PyObject * callback;
    PyObject * userdata;
    xmlSecKeyPtr ptr;
    PyObject * ret;
    void * cb;
    PasswordCallbackUserDataType cbdata_;
    PasswordCallbackUserDataType * cbdata;

    static char * kwlist[] = {"filename", "pwd", "pwdCallback", "pwdCallbackCtx", NULL};

    filename = password = NULL;
    callback = userdata = NULL;
    ptr = NULL;
    ret = NULL;
    cb = NULL;
    cbdata = NULL;

    memset(&cbdata_, '\0', sizeof(cbdata_));

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|sOO", kwlist, &filename, &password, &callback, &userdata))
    {
        return NULL;
    }

    if (NULL != callback)
    {
        Py_INCREF(callback);
        cbdata_.callable = callback;

        if (NULL != userdata)
        {
            Py_INCREF(userdata);
            cbdata_.userdata = userdata;
        }

        cbdata = &cbdata_;
        cb = (void *)&xmlsec1_xmlSecPasswordCallbackWrapper;
    }

    if (NULL == (ptr = xmlSecCryptoAppPkcs12Load(filename, password, cb, cbdata)))
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppPkcs12Load);

        if (NULL != cbdata)
        {
            Py_XDECREF(cbdata->callable);
            Py_XDECREF(cbdata->userdata);
        }

        return NULL;
    }

    if (NULL != cbdata)
    {
        Py_XDECREF(cbdata->callable);
        Py_XDECREF(cbdata->userdata);
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecKeyPtr(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecKeyPtr);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecCryptoAppPkcs12LoadMemory(PyObject * self, PyObject * args, PyObject * kwds)
{
    PyObject * arg1;
    char * password;
    PyObject * callback;
    PyObject * userdata;
    xmlSecKeyPtr ptr;
    PyObject * ret;
    void * cb;
    xmlSecByte * data;
    xmlSecSize dataSize;
    PasswordCallbackUserDataType cbdata_;
    PasswordCallbackUserDataType * cbdata;

    static char * kwlist[] = {"data", "pwd", "pwdCallback", "pwdCallbackCtx", NULL};

    password = NULL;
    arg1 = NULL;
    callback = userdata = NULL;
    ptr = NULL;
    ret = NULL;
    cb = NULL;
    cbdata = NULL;

    memset(&cbdata_, '\0', sizeof(cbdata_));

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|sOO", kwlist, &arg1, &password, &callback, &userdata))
    {
        return NULL;
    }

    if (0 != xmlsec1_ByteArrayOrBytesToXmlSecBytes(arg1, &data, &dataSize))
    {
        ENSURE_EXCEPTION_SET(xmlsec1_ByteArrayOrBytesToXmlSecBytes);
        return NULL;
    }

    if (NULL != callback)
    {
        Py_INCREF(callback);
        cbdata_.callable = callback;

        if (NULL != userdata)
        {
            Py_INCREF(userdata);
            cbdata_.userdata = userdata;
        }

        cbdata = &cbdata_;
        cb = (void *)&xmlsec1_xmlSecPasswordCallbackWrapper;
    }

    if (NULL == (ptr = xmlSecCryptoAppPkcs12LoadMemory(data, dataSize, password, cb, cbdata)))
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppPkcs12LoadMemory);

        if (NULL != cbdata)
        {
            Py_XDECREF(cbdata->callable);
            Py_XDECREF(cbdata->userdata);
        }

        PyMem_Del(data);
        return NULL;
    }

    PyMem_Del(data);
    if (NULL != cbdata)
    {
        Py_XDECREF(cbdata->callable);
        Py_XDECREF(cbdata->userdata);
    }

    if (NULL == (ret = xmlsec1mod_wrap_xmlSecKeyPtr(ptr)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_wrap_xmlSecKeyPtr);
        return NULL;
    }

    return ret;
}



static PyObject * xmlsec1_xmlSecCryptoAppKeyCertLoad(PyObject * self, PyObject * args, PyObject * kwds)
{
    PyObject * arg1;
    char * filename;
    int arg3;
    xmlSecKeyPtr key;
    xmlSecKeyDataFormat format;

    static char * kwlist[] = {"key", "filename", "format", NULL};

    arg1 = NULL;
    filename = NULL;
    arg3 = 0;
    key = NULL;
    format = xmlSecKeyDataFormatUnknown;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "Osi", kwlist, &arg1, &filename, &arg3))
    {
        return NULL;
    }

    if (NULL == (key = xmlsec1mod_unwrap_xmlSecKeyPtr(arg1)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_unwrap_xmlSecKeyPtr);
        return NULL;
    }

    format = (xmlSecKeyDataFormat)arg3;

    if (0 != xmlSecCryptoAppKeyCertLoad(key, filename, format))
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppKeyCertLoad);
        return NULL;
    }

    Py_RETURN_NONE;
}



static PyObject * xmlsec1_xmlSecCryptoAppKeyCertLoadMemory(PyObject * self, PyObject * args, PyObject * kwds)
{
    PyObject * arg1;
    PyObject * arg2;
    int arg3;
    xmlSecKeyPtr key;
    xmlSecByte * data;
    xmlSecSize dataSize;
    xmlSecKeyDataFormat format;

    static char * kwlist[] = {"key", "data", "format", NULL};

    arg1 = arg2 = NULL;
    arg3 = 0;
    key = NULL;
    data = NULL;
    dataSize = 0;
    format = xmlSecKeyDataFormatUnknown;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOi", kwlist, &arg1, &arg2, &arg3))
    {
        return NULL;
    }

    if (NULL == (key = xmlsec1mod_unwrap_xmlSecKeyPtr(arg1)))
    {
        ENSURE_EXCEPTION_SET(xmlsec1mod_unwrap_xmlSecKeyPtr);
        return NULL;
    } 

    if (0 != xmlsec1_ByteArrayOrBytesToXmlSecBytes(arg2, &data, &dataSize))
    {
        ENSURE_EXCEPTION_SET(xmlsec1_ByteArrayOrBytesToXmlSecBytes);
        return NULL;
    }

    format = (xmlSecKeyDataFormat)arg3;

    if (0 != xmlSecCryptoAppKeyCertLoadMemory(key, data, dataSize, format))
    {
        ENSURE_EXCEPTION_SET(xmlSecCryptoAppKeyCertLoadMemory);
        PyMem_Del(data);
        return NULL;
    }

    PyMem_Del(data);
    Py_RETURN_NONE;
}






#if 0
-- int xmlSecCryptoInit(void);
-- int xmlSecCryptoShutdown(void);
-- int xmlSecCryptoKeysMngrInit(xmlSecKeysMngrPtr mngr);
-- #define             xmlSecKeyDataAesId
-- xmlSecKeyDataId     xmlSecKeyDataAesGetKlass            (void);
-- #define             xmlSecKeyDataDesId
-- xmlSecKeyDataId     xmlSecKeyDataDesGetKlass            (void);
-- #define             xmlSecKeyDataDsaId
-- xmlSecKeyDataId     xmlSecKeyDataDsaGetKlass            (void);
-- #define             xmlSecKeyDataGost2001Id
-- xmlSecKeyDataId     xmlSecKeyDataGost2001GetKlass       (void);
-- #define             xmlSecKeyDataHmacId
-- xmlSecKeyDataId     xmlSecKeyDataHmacGetKlass           (void);
-- #define             xmlSecKeyDataRsaId
-- xmlSecKeyDataId     xmlSecKeyDataRsaGetKlass            (void);
-- #define             xmlSecKeyDataX509Id
-- xmlSecKeyDataId     xmlSecKeyDataX509GetKlass           (void);
-- #define             xmlSecKeyDataRawX509CertId
-- xmlSecKeyDataId     xmlSecKeyDataRawX509CertGetKlass    (void);
-- #define             xmlSecX509StoreId
-- xmlSecKeyDataStoreId  xmlSecX509StoreGetKlass           (void);
-- #define             xmlSecTransformAes128CbcId
-- xmlSecTransformId   xmlSecTransformAes128CbcGetKlass    (void);
-- #define             xmlSecTransformAes192CbcId
-- xmlSecTransformId   xmlSecTransformAes192CbcGetKlass    (void);
-- #define             xmlSecTransformAes256CbcId
-- xmlSecTransformId   xmlSecTransformAes256CbcGetKlass    (void);
-- #define             xmlSecTransformKWAes128Id
-- xmlSecTransformId   xmlSecTransformKWAes128GetKlass     (void);
-- #define             xmlSecTransformKWAes192Id
-- xmlSecTransformId   xmlSecTransformKWAes192GetKlass     (void);
-- #define             xmlSecTransformKWAes256Id
-- xmlSecTransformId   xmlSecTransformKWAes256GetKlass     (void);
-- #define             xmlSecTransformDes3CbcId
-- xmlSecTransformId   xmlSecTransformDes3CbcGetKlass      (void);
-- #define             xmlSecTransformKWDes3Id
-- xmlSecTransformId   xmlSecTransformKWDes3GetKlass       (void);
-- #define             xmlSecTransformDsaSha1Id
-- xmlSecTransformId   xmlSecTransformDsaSha1GetKlass      (void);
-- #define             xmlSecTransformGost2001GostR3411_94Id
-- xmlSecTransformId   xmlSecTransformGost2001GostR3411_94GetKlass (void);
-- #define             xmlSecTransformHmacMd5Id
-- xmlSecTransformId   xmlSecTransformHmacMd5GetKlass      (void);
-- #define             xmlSecTransformHmacRipemd160Id
-- xmlSecTransformId   xmlSecTransformHmacRipemd160GetKlass (void);
-- #define             xmlSecTransformHmacSha1Id
-- xmlSecTransformId   xmlSecTransformHmacSha1GetKlass     (void);
-- #define             xmlSecTransformHmacSha224Id
-- xmlSecTransformId   xmlSecTransformHmacSha224GetKlass   (void);
-- #define             xmlSecTransformHmacSha256Id
-- xmlSecTransformId   xmlSecTransformHmacSha256GetKlass   (void);
-- #define             xmlSecTransformHmacSha384Id
-- xmlSecTransformId   xmlSecTransformHmacSha384GetKlass   (void);
-- #define             xmlSecTransformHmacSha512Id
-- xmlSecTransformId   xmlSecTransformHmacSha512GetKlass   (void);
-- #define             xmlSecTransformMd5Id
-- xmlSecTransformId   xmlSecTransformMd5GetKlass          (void);
-- #define             xmlSecTransformRipemd160Id
-- xmlSecTransformId   xmlSecTransformRipemd160GetKlass    (void);
-- #define             xmlSecTransformRsaMd5Id
-- xmlSecTransformId   xmlSecTransformRsaMd5GetKlass       (void);
-- #define             xmlSecTransformRsaRipemd160Id
-- xmlSecTransformId   xmlSecTransformRsaRipemd160GetKlass (void);
-- #define             xmlSecTransformRsaSha1Id
-- xmlSecTransformId   xmlSecTransformRsaSha1GetKlass      (void);
-- #define             xmlSecTransformRsaSha224Id
-- xmlSecTransformId   xmlSecTransformRsaSha224GetKlass    (void);
-- #define             xmlSecTransformRsaSha256Id
-- xmlSecTransformId   xmlSecTransformRsaSha256GetKlass    (void);
-- #define             xmlSecTransformRsaSha384Id
-- xmlSecTransformId   xmlSecTransformRsaSha384GetKlass    (void);
-- #define             xmlSecTransformRsaSha512Id
-- xmlSecTransformId   xmlSecTransformRsaSha512GetKlass    (void);
-- #define             xmlSecTransformRsaPkcs1Id
-- xmlSecTransformId   xmlSecTransformRsaPkcs1GetKlass     (void);
-- #define             xmlSecTransformRsaOaepId
-- xmlSecTransformId   xmlSecTransformRsaOaepGetKlass      (void);
-- #define             xmlSecTransformGostR3411_94Id
-- xmlSecTransformId   xmlSecTransformGostR3411_94GetKlass (void);
-- #define             xmlSecTransformSha1Id
-- xmlSecTransformId   xmlSecTransformSha1GetKlass         (void);
-- #define             xmlSecTransformSha224Id
-- xmlSecTransformId   xmlSecTransformSha224GetKlass       (void);
-- #define             xmlSecTransformSha256Id
-- xmlSecTransformId   xmlSecTransformSha256GetKlass       (void);
-- #define             xmlSecTransformSha384Id
-- xmlSecTransformId   xmlSecTransformSha384GetKlass       (void);
-- #define             xmlSecTransformSha512Id
-- xmlSecTransformId   xmlSecTransformSha512GetKlass       (void);
-- int xmlSecCryptoAppInit(const char *config);
-- int xmlSecCryptoAppShutdown(void);
-- int                 xmlSecCryptoAppDefaultKeysMngrInit  (xmlSecKeysMngrPtr mngr);
-- int xmlSecCryptoAppDefaultKeysMngrAdoptKey(xmlSecKeysMngrPtr mngr, xmlSecKeyPtr key);
-- int xmlSecCryptoAppDefaultKeysMngrLoad  (xmlSecKeysMngrPtr mngr, const char *uri);
-- int xmlSecCryptoAppDefaultKeysMngrSave  (xmlSecKeysMngrPtr mngr, const char *filename, xmlSecKeyDataType type);
-- int xmlSecCryptoAppKeysMngrCertLoad(xmlSecKeysMngrPtr mngr, const char *filename, xmlSecKeyDataFormat format, xmlSecKeyDataType type);
-- int xmlSecCryptoAppKeysMngrCertLoadMemory(xmlSecKeysMngrPtr mngr, const xmlSecByte *data, xmlSecSize dataSize, xmlSecKeyDataFormat format, xmlSecKeyDataType type);
-- xmlSecKeyPtr xmlSecCryptoAppKeyLoad(const char *filename, xmlSecKeyDataFormat format, const char *pwd, void *pwdCallback, void *pwdCallbackCtx);
-- xmlSecKeyPtr xmlSecCryptoAppKeyLoadMemory(const xmlSecByte *data, xmlSecSize dataSize, xmlSecKeyDataFormat format, const char *pwd, void *pwdCallback, void *pwdCallbackCtx);
-- xmlSecKeyPtr xmlSecCryptoAppPkcs12Load(const char *filename, const char *pwd, void *pwdCallback, void *pwdCallbackCtx);
-- xmlSecKeyPtr xmlSecCryptoAppPkcs12LoadMemory(const xmlSecByte *data, xmlSecSize dataSize, const char *pwd, void *pwdCallback, void *pwdCallbackCtx);
-- int xmlSecCryptoAppKeyCertLoad(xmlSecKeyPtr key, const char *filename, xmlSecKeyDataFormat format);
-- int xmlSecCryptoAppKeyCertLoadMemory(xmlSecKeyPtr key, const xmlSecByte *data, xmlSecSize dataSize, xmlSecKeyDataFormat format);
-- POINTLESS: void * xmlSecCryptoAppGetDefaultPwdCallback(void);
#endif

#endif
